#!/usr/bin/python
# -*- coding: UTF-8 -*-

#列表页接口
def listPages(page = 1):
    url = 'http://datacenter-web.eastmoney.com/api/data/v1/get?sortColumns=PUBLIC_START_DATE&sortTypes=-1&pageSize=50&pageNumber='+str(page)+'&reportName=RPT_BOND_CB_LIST&columns=ALL&quoteColumns=f2~01~CONVERT_STOCK_CODE~CONVERT_STOCK_PRICE%2Cf235~10~SECURITY_CODE~TRANSFER_PRICE%2Cf236~10~SECURITY_CODE~TRANSFER_VALUE%2Cf2~10~SECURITY_CODE~CURRENT_BOND_PRICE%2Cf237~10~SECURITY_CODE~TRANSFER_PREMIUM_RATIO%2Cf239~10~SECURITY_CODE~RESALE_TRIG_PRICE%2Cf240~10~SECURITY_CODE~REDEEM_TRIG_PRICE%2Cf23~01~CONVERT_STOCK_CODE~PBV_RATIO&source=WEB&client=WEB'
    return url

#转债详情页接口 filter=(SECURITY_CODE="123125") 123125 为转债代码
#列表接口已有该接口数据，暂不使用该接口
itemPage = 'http://datacenter-web.eastmoney.com/api/data/v1/get?reportName=RPT_BOND_CB_LIST&columns=ALL&quoteColumns=&source=WEB&client=WEB&filter=(SECURITY_CODE="123125")&_=1632993338065'

#转债中签信息
def zqInfo(bond_code):
    url = 'http://datacenter-web.eastmoney.com/api/data/v1/get?reportName=RPT_CB_BALLOTNUM&columns=ALL&quoteColumns=&source=WEB&client=WEB&filter=(SECURITY_CODE="'+bond_code+'")'
    return url

#转债筹资用途接口
def czInfo(bond_code):
    url = 'http://datacenter-web.eastmoney.com/api/data/v1/get?reportName=RPT_BOND_BS_OPRFINVESTITEM&columns=ALL&quoteColumns=&source=WEB&client=WEB&filter=(SECURITY_CODE="'+bond_code+'")&sortColumns=SORT&sortTypes=1'
    return url

#转债 重要日期信息
def zyDate(bond_code):
    url = 'http://datacenter-web.eastmoney.com/api/data/v1/get?reportName=RPT_CB_IMPORTANTDATE&columns=ALL&quoteColumns=&source=WEB&client=WEB&filter=(SECURITY_CODE="'+bond_code+'")'
    return url

#所属板块sz002091
#code 为正股代码
#获取转债所属板块
def ssbkUrl(code, bond_type):
    ssbk = "http://emweb.eastmoney.com/CoreConception/PageAjax?"+"code="+bond_type+code
    return ssbk

#secid 0.123125 0为深市，1为上市 secid=0.123125
#获取转债当天的交易数据
def bondItemDataUrl(bond_code, bond_type):
    url = 'http://push2.eastmoney.com/api/qt/stock/get?ut=bd1d9ddb04089700cf9c27f6f7426281&fields=f43,f169,f170,f46,f60,f84,f116,f44,f45,f171,f126,f47,f48,f168,f164,f49,f161,f55,f92,f59,f152,f167,f50,f86,f71,f172,f182,f191,f192,f532&type=CT&sty=FDPBPFB&st=z'
    bondType = '0'
    if bond_type == 'SH':
        bondType = '1'

    uri = url+'&secid='+bondType+'.'+bond_code

    return uri


#bk_type
#概念板块：3
#行业板块：2
#地区板块：1
#pn 页码
def bksUrl(bk_type, pn=1):
    url = 'http://4.push2.eastmoney.com/api/qt/clist/get?pn='+str(pn)+'&pz=20&po=1&np=1&ut=bd1d9ddb04089700cf9c27f6f7426281&fltt=2&invt=2&fid=f3&fs=m:90+t:'+str(bk_type)+'+f:!50&fields=f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,f23,f24,f25,f26,f22,f33,f11,f62,f128,f136,f115,f152,f124,f107,f104,f105,f140,f141,f207,f208,f209,f222'
    return url